package com.study.shirojwtredis.controller;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @ClassName TestController
 * @Author One_llx
 * @Date 2019/11/21 0021 下午 10:10
 * @Version 1.0
 */@CrossOrigin(origins = "*", maxAge = 3600, methods = {RequestMethod.POST, RequestMethod.GET})
@RestController
@RequestMapping("/test")
public class TestController {

    @RequestMapping(value = "/find/list", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    public String findList(HttpSession session,
                           HttpServletResponse response) {
//        System.out.println(1/0);

        session.setAttribute("hello","123");
        Cookie cookie=new Cookie("username","23");
        response.addCookie(cookie);
        return session.getId();
    }
}
